package com.toweave.starter.beans;


import android.os.Parcel;
import android.os.Parcelable;

import androidx.annotation.NonNull;


public class UserBean extends BaseBean implements Parcelable {
  private int id;
  private String name;
  private String code;

  public UserBean(int id, String name, String code) {
    this.id = id;
    this.name = name;
    this.code = code;
  }

  // getter and setter methods
  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(String name) {
    this.name = name;
  }

  public String getCode() {
    return code;
  }

  public void setCode(String code) {
    this.code = code;
  }

  // 使用 putParcelableArrayList
  protected UserBean(Parcel in) {
    id = in.readInt();
    name = in.readString();
    code = in.readString();
  }

  public static final Creator<UserBean> CREATOR = new Creator<UserBean>() {
    @Override
    public UserBean createFromParcel(Parcel in) {
      return new UserBean(in);
    }

    @Override
    public UserBean[] newArray(int size) {
      return new UserBean[size];
    }
  };

  @Override
  public int describeContents() {
    return 0;
  }

  @Override
  public void writeToParcel(@NonNull Parcel dest, int flags) {
    dest.writeInt(id);
    dest.writeString(name);
    dest.writeString(code);
  }
}
